package com.tarena.csmall.sentinel.demo03.controller;

import com.alibaba.csp.sentinel.Entry;
import com.alibaba.csp.sentinel.SphU;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.alibaba.csp.sentinel.slots.block.flow.FlowException;
import com.tarena.csmall.sentinel.demo03.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author java@tedu.cn
 * @version 1.0
 */
@RestController
public class HelloController {
    @Autowired
    private HelloService helloService;
    @GetMapping("/hello")
    @SentinelResource(value="sayHi",blockHandler = "blockError")
    public String sayHi(String name){
        System.out.println("controller方法");
        String result=helloService.sayHi(name);
        return result;
    }
    public String blockError(String name,BlockException e){
        //记录日志,将数据写入日志,
        return "不在向下调用";
    }
}
